﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using BTN04.DTO;
using System.Collections.Generic;
namespace BTN04.DAO
{
    public class LoaiSanPhamDAO
    {
        public List<LoaiSanPhamDTO> DanhSachLoaiSanPham()
        {
            List<LoaiSanPhamDTO> _danhSach = new List<LoaiSanPhamDTO>();
            string sql = "SELECT* FROM LOAISANPHAM";
            SqlConnection cnn = new SqlConnection(DataProvider.ConnectionString);
            SqlCommand comand = new SqlCommand(sql,cnn);
            cnn.Open();
            SqlDataReader read =comand.ExecuteReader();
            while (read.Read())
            {
                LoaiSanPhamDTO spDTO = new LoaiSanPhamDTO();
                spDTO.MaLoaiSanPham = int.Parse(read["MaLoaiSanPham"].ToString());
                spDTO.TenLoaiSanPham = read["TenLoaiSanPham"].ToString();
                _danhSach.Add(spDTO);
            }
            return _danhSach;
        }
    }
}
